package OrderManager;
import Method.Conexcute;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns = "/Addorder")
public class AddorderServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        System.out.println("ccccccccccccccccccccccc");
        String us_id= request.getParameter("us_id");
        String pr_id=request.getParameter("pr_id");
        String price=request.getParameter("price");
        String number=request.getParameter("number");
        String date=request.getParameter("date");
        Conexcute conexcute=new Conexcute();
        if(conexcute.execute("insert into `rder` (`us_id`,`pr_id`,`price`,`number`,`date`) values ( '"+us_id+"', '"+pr_id+"','"+price+"','"+number+"','"+date+"');")){
            response.setContentType("text/html");
            response.setCharacterEncoding("UTF-8");
            response.getWriter().println("数据添加成功");
            response.sendRedirect("OrderManager/order.jsp");
        }
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }
}
